//Pull in DMA commands
#include <spu_mfcio.h>

//Struct for communication with the PPE
typedef struct {
	float speed;     //input parameter
	float num_hours; //input parameter
	float distance;  //output parameter
	float padding;   //pad the struct a multiple of 16 bytes
} program_data;

int main(unsigned long long spe_id, unsigned long long program_data_ea, unsigned 
long long env) {
	program_data pd __attribute__((aligned(16)));
	int tag_id = 0;

	//READ DATA IN
	//Initiate copy
	mfc_get(&pd, program_data_ea, sizeof(pd), tag_id, 0, 0);
	//Wait for completion
	mfc_write_tag_mask(1<<tag_id);
	mfc_read_tag_status_any();

	//PROCESS DATA
	pd.distance = pd.speed * pd.num_hours;

	//WRITE RESULTS OUT
	//Initiate copy
	mfc_put(&pd, program_data_ea, sizeof(program_data), tag_id, 0, 0);
	//Wait for completion
	mfc_write_tag_mask(1<<tag_id);
	mfc_read_tag_status_any();
	return 0;
}

